#include "doubletostringtest.h"

bool DoubleToStringTest::run() {
    short count=0;

    if (!DoubleToStringTest::doubleToStringTest())
        std::cout << "ERROR " << ++count << " DoubleToStringTest::doubleToStringTest() faild!" << std::endl;
    if (!DoubleToStringTest::charToStringTest())
        std::cout << "ERROR " << ++count << " DoubleToStringTest::charToStringTest() faild!" << std::endl;

    return count==0;
}

bool DoubleToStringTest::doubleToStringTest() {
    std::string *testString;
    testString=&DoubleToString::dts(3.054);
    assert(!testString->compare("3.054"));
    delete testString;
    testString=&DoubleToString::dts(0);
    assert(!testString->compare("0"));
    delete testString;
    testString=&DoubleToString::dts(-3.532);
    assert(!testString->compare("-3.532"));
    delete testString;
    testString=&DoubleToString::dts(1234567890.1234567890);
    assert(!testString->compare("1.23457e+09"));
    delete testString;
    return true;
}

bool DoubleToStringTest::charToStringTest() {
    std::string *testString;
    testString=&DoubleToString::cts('a');
    assert(!testString->compare("a"));
    delete testString;
    testString=&DoubleToString::cts('0');
    assert(!testString->compare("0"));
    delete testString;
    testString=&DoubleToString::cts('Y');
    assert(!testString->compare("Y"));
    delete testString;
    testString=&DoubleToString::cts(';');
    assert(!testString->compare(";"));
    delete testString;
    return true;
}

